﻿Imports BUS
Imports DTO

Public Class frmDangNhap
    Dim flag As Boolean
    Public Property FlagProperty() As Boolean
        Get
            Return flag
        End Get
        Set(ByVal value As Boolean)
            flag = value
        End Set
    End Property

    Public nvienDTo As NhanVienDTO
    Public Property NvienDToProperty() As NhanVienDTO
        Get
            Return nvienDTo
        End Get
        Set(ByVal value As NhanVienDTO)
            nvienDTo = value
        End Set
    End Property
    Private Sub frmDangNhap_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub btnDangNhap_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDangNhap.Click
        Dim str As String
        If txtIDNhanVien.Text.Length = 0 Then
            str += "ID Nhân Viên không được bỏ tóng" & vbCrLf
        End If
        If txtMatKhau.Text.Length = 0 Then
            str += "Mật khẩu không được bỏ trống" & vbCrLf
        End If
        If str IsNot Nothing Then
            MessageBox.Show(str)
        Else
            Dim dt As New DataTable()
            Dim nvienBus As New NhanVienBUS()
            dt = nvienBus.LayThongTinNhanVien(txtIDNhanVien.Text, txtMatKhau.Text)
            If dt.Rows.Count <> 0 Then
                flag = True
                nvienDTo = New NhanVienDTO()
                nvienDTo.ID = Convert.ToInt32(dt.Rows(0)("ID"))
                nvienDTo.IDNhanVien = dt.Rows(0)("IDNhanVien")
                nvienDTo.MatKhau = dt.Rows(0)("MatKhau")
                nvienDTo.TenNhanVien = dt.Rows(0)("TenNhanVien")
                nvienDTo.DiaChi = dt.Rows(0)("DiaChi")
                nvienDTo.DienThoai = dt.Rows(0)("DienThoai")
                nvienDTo.NgaySinh = dt.Rows(0)("NgaySinh")
                nvienDTo.MaChucVu = dt.Rows(0)("MaChucVu")
                Me.Close()
            End If
        End If
    End Sub

    Private Sub btnHuy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHuy.Click
        Me.Close()
    End Sub
End Class